// ;
// $(function () {

//浏览器检测
function sysCheckFn(obj, fun, type, dataId) {
    var bs = BrowserDetect.browser,
        vn = BrowserDetect.version,
        os = BrowserDetect.OS;

    var _ele = '<div class="loginfase__wrap"><div class="pb10 ml20 mr20">';
    _ele += '<div class="mt5 mb10"><span class="fs14">在互动直播开始前，需先检查浏览器及网络配置是否符合要求<br />浏览器要求：谷歌Chrome浏览器，版本V55.0及以上。</span></div>';
    _ele += '<blockquote><p>当前：<span id="browserName"></span> 浏览器，版本 V<span id="browserVersion"></span> 及以上。</p></blockquote>';
    _ele += '<div class="mt10"><span class="fs14">网络环境要求：上行带宽达到 2Mbps 或以上。</span></div>';
    _ele += '<blockquote><p>当前：系统为 <span id="sysName"></span>，带宽正常，达到要求。</p></blockquote>';
    _ele += '</div></div>';

    layer.open({
        type: 0,
        title: '<span class="fs18">友情提示</span>',
        area: ['580px', '360px'],
        shadeClose: false,
        skin: 'lay_ppComment__wrap',
        content: _ele,
        btn: ['进入学习', '系统检测'],
        success: function () {
            $('#browserName').html(bs);
            $('#browserVersion').html(vn);
            $('#sysName').html(os);
        },
        yes: function (index, layero) {
            if (bs != 'Chrome') {
                layer.confirm('对不起，系统检测到当前非谷歌浏览器。是否下载安装？',
                    {icon: 3, title: '友情提示', btn: ['下载安装Chrome浏览器'], closeBtn: 0, skin: 'lay_ppComment__wrap'},
                    function (index) {
                        //引导下载浏览器
                        window.location.href = "https://www.google.cn/chrome/"
                        layer.close(index);
                    });
                return
            } else if (bs == 'Chrome' && vn <= 56) {
                layer.msg('对不起，当前谷歌Chrome浏览器的版本太低，请升级后再学习~~~')
                return
            } else {
                //进入直播间
                if (type == 1) {
                    openPlayCourse(obj, fun);
                } else if (type == 2) {
                    window.location.href = baseloaction + "/web/uc/play/toPlayCourse?packageId=0&courseId=" + dataId + "&catalogId=0&type=LOBBY";
                } else if (type == 3) {
                    console.log(dataId);
                    var ids = dataId.split("|");
                    window.location.href = baseloaction + "/web/uc/play/toPlayCourse?packageId=0&courseId=" + ids[0] + "&catalogId=" + ids[1] + "&type=LOBBY"
                }else if (type ==4) {
                    var ids = dataId.split("|");
                    window.location.href = baseloaction +'/web/uc/play/toPlayCourse?packageId=' + ids[0] + '&courseId=' +ids[1] + '&catalogId=' + ids[2] + '&type=LOBBY';
                }
                layer.close(index);
            }

        },
        btn2: function (index, layero) {
            window.location.href = "https://livec2.96koo.net/webrtczj.html"
        }
    })
};

//系统检测
// sysCheckFn()

// })

//浏览器参数
var BrowserDetect = {
    init: function () {
        this.browser = this.searchString(this.dataBrowser) || "An unknown browser";
        this.version = this.searchVersion(navigator.userAgent)
            || this.searchVersion(navigator.appVersion)
            || "an unknown version";
        this.OS = this.searchString(this.dataOS) || "an unknown OS";
    },
    searchString: function (data) {
        for (var i = 0; i < data.length; i++) {
            var dataString = data[i].string;
            var dataProp = data[i].prop;
            this.versionSearchString = data[i].versionSearch || data[i].identity;
            if (dataString) {
                if (dataString.indexOf(data[i].subString) != -1)
                    return data[i].identity;
            }
            else if (dataProp)
                return data[i].identity;
        }
    },
    searchVersion: function (dataString) {
        var index = dataString.indexOf(this.versionSearchString);
        if (index == -1) return;
        return parseFloat(dataString.substring(index + this.versionSearchString.length + 1));
    },
    dataBrowser: [
        {
            string: navigator.userAgent,
            subString: "Chrome",
            identity: "Chrome"
        },
        {
            string: navigator.userAgent,
            subString: "OmniWeb",
            versionSearch: "OmniWeb/",
            identity: "OmniWeb"
        },
        {
            string: navigator.vendor,
            subString: "Apple",
            identity: "Safari",
            versionSearch: "Version"
        },
        {
            prop: window.opera,
            identity: "Opera"
        },
        {
            string: navigator.vendor,
            subString: "iCab",
            identity: "iCab"
        },
        {
            string: navigator.vendor,
            subString: "KDE",
            identity: "Konqueror"
        },
        {
            string: navigator.userAgent,
            subString: "Firefox",
            identity: "Firefox"
        },
        {
            string: navigator.vendor,
            subString: "Camino",
            identity: "Camino"
        },
        {       // for newer Netscapes (6+)
            string: navigator.userAgent,
            subString: "Netscape",
            identity: "Netscape"
        },
        {
            string: navigator.userAgent,
            subString: "MSIE",
            identity: "Internet Explorer",
            versionSearch: "MSIE"
        },
        {
            string: navigator.userAgent,
            subString: "Gecko",
            identity: "Mozilla",
            versionSearch: "rv"
        },
        {        // for older Netscapes (4-)
            string: navigator.userAgent,
            subString: "Mozilla",
            identity: "Netscape",
            versionSearch: "Mozilla"
        }
    ],
    dataOS: [
        {
            string: navigator.platform,
            subString: "Win",
            identity: "Windows"
        },
        {
            string: navigator.platform,
            subString: "Mac",
            identity: "Mac"
        },
        {
            string: navigator.userAgent,
            subString: "iPhone",
            identity: "iPhone/iPod"
        },
        {
            string: navigator.platform,
            subString: "Linux",
            identity: "Linux"
        }
    ]

};
BrowserDetect.init();